package com.googlecode.groovy_toy_orm.framework

import org.apache.commons.lang3.StringEscapeUtils
import org.apache.log4j.PatternLayout
import org.apache.log4j.spi.LoggingEvent

/**
 * @author: DavydovMD
 * Date: 16.05.13
 * Time: 14:28
 */
class ReportNGTestLayout extends PatternLayout{
    @Override
    public String format(LoggingEvent event) {
        String newMsg= StringEscapeUtils.escapeHtml4(event.message.toString())
        //newMsg = new String(newMsg.toString().getBytes(Charset.forName("cp1251")), Charset.forName("utf-8"));
        LoggingEvent encodedEvent = new LoggingEvent(event.fqnOfCategoryClass, event.logger, event.timeStamp, event.level, newMsg, event.getThrowableInformation()?.throwable)
        String baseFmt = super.format(encodedEvent).replace("@{{","<").replace("@}}",">")
        return "<TABLE><TR><TD>${BaseFunctionalTest.getIndentation().replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")}</TD><TD>${baseFmt}</TD></TR></TABLE>"
    }

}
